<?php
$tmp = '../tmp/';
if (!is_dir($tmp)) {
    die(json_encode(['code' => 0, 'data' => []]));
}
$dirData = scandir($tmp);
// 忽略的文件 . ..
$ignore = ['.', '..','.DS_Store'];
// 删除6小时之前的文件
$file = [];
foreach($dirData as $Key => $value){
    $filePath = $tmp.$value;
    $ctime = filectime($filePath);
    if (in_array($value, $ignore))
    {
        continue;
    }
    if (($ctime+ 3600*6) < time())
    {
        @unlink($filePath);
        unset($dirData[$Key]);
        continue;
    }
    if (is_file($filePath)) {
        $file[] = $value;
    }
}

die(json_encode(['code' => 0, 'data' => array_reverse($file)]));